package com.gblfy.controller;

import com.gblfy.service.IPreviewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @author gblfy
 * @date 2021-10-28
 */
@Api(tags = "在线预览入口")
@RestController
@RequestMapping("/file/onlinePreview")
public class PreviewController {

    @Autowired
    private IPreviewService previewService;//在线预览处理类

    /**
     * 在线预览主入口
     *
     * @param fileUrl
     * @param response
     * @throws Exception
     */
    @ApiOperation("在线预览主方法")
    @PostMapping("/api")
    public void onlinePreview(@RequestParam("fileUrl") String fileUrl, HttpServletResponse response) throws Exception {
        previewService.onlinePreview(fileUrl, response);
    }
}
